﻿namespace TriangleGames.TrainResEditor
{
    using TriangleGames.TrainRes;
    using System;
    using System.Globalization;
    using System.Runtime.CompilerServices;
    using UnityEditor;
    using UnityEngine;

    internal static class VariableEditor
    {
        [CompilerGenerated]
        private static bool DebugVariables__BackingField;

        private static FsmBool DoFsmBoolPopup(GUIContent label, Fsm fsm, FsmBool fsmBool)
        {
            fsmBool = ((FsmBool) FsmEditorGUILayout.Popup(label, fsmBool, (fsm != null) ? ((INamedVariable[]) fsm.Variables.BoolVariables) : null, (FsmVariables.GlobalVariables != null) ? ((INamedVariable[]) FsmVariables.GlobalVariables.BoolVariables) : null)) ?? new FsmBool("");
            fsmBool.UseVariable = true;
            return fsmBool;
        }

        private static FsmColor DoFsmColorPopup(GUIContent label, Fsm fsm, FsmColor fsmColor)
        {
            fsmColor = ((FsmColor) FsmEditorGUILayout.Popup(label, fsmColor, (fsm != null) ? ((INamedVariable[]) fsm.Variables.ColorVariables) : null, (FsmVariables.GlobalVariables != null) ? ((INamedVariable[]) FsmVariables.GlobalVariables.ColorVariables) : null)) ?? new FsmColor("");
            fsmColor.UseVariable = true;
            return fsmColor;
        }

        private static FsmFloat DoFsmFloatPopup(GUIContent label, Fsm fsm, FsmFloat fsmFloat)
        {
            fsmFloat = ((FsmFloat) FsmEditorGUILayout.Popup(label, fsmFloat, (fsm != null) ? ((INamedVariable[]) fsm.Variables.FloatVariables) : null, (FsmVariables.GlobalVariables != null) ? ((INamedVariable[]) FsmVariables.GlobalVariables.FloatVariables) : null)) ?? new FsmFloat("");
            fsmFloat.UseVariable = true;
            return fsmFloat;
        }

        private static FsmGameObject DoFsmGameObjectPopup(GUIContent label, Fsm fsm, FsmGameObject fsmGameObject)
        {
            fsmGameObject = ((FsmGameObject) FsmEditorGUILayout.Popup(label, fsmGameObject, (fsm != null) ? ((INamedVariable[]) fsm.Variables.GameObjectVariables) : null, (FsmVariables.GlobalVariables != null) ? ((INamedVariable[]) FsmVariables.GlobalVariables.GameObjectVariables) : null)) ?? new FsmGameObject("");
            fsmGameObject.UseVariable = true;
            return fsmGameObject;
        }

        private static FsmInt DoFsmIntPopup(GUIContent label, Fsm fsm, FsmInt fsmInt)
        {
            fsmInt = ((FsmInt) FsmEditorGUILayout.Popup(label, fsmInt, (fsm != null) ? ((INamedVariable[]) fsm.Variables.IntVariables) : null, (FsmVariables.GlobalVariables != null) ? ((INamedVariable[]) FsmVariables.GlobalVariables.IntVariables) : null)) ?? new FsmInt("");
            fsmInt.UseVariable = true;
            return fsmInt;
        }

        private static FsmMaterial DoFsmMaterialPopup(GUIContent label, Fsm fsm, FsmMaterial fsmObject)
        {
            fsmObject = ((FsmMaterial) FsmEditorGUILayout.Popup(label, fsmObject, (fsm != null) ? ((INamedVariable[]) fsm.Variables.MaterialVariables) : null, (FsmVariables.GlobalVariables != null) ? ((INamedVariable[]) FsmVariables.GlobalVariables.MaterialVariables) : null)) ?? new FsmMaterial("");
            fsmObject.UseVariable = true;
            return fsmObject;
        }

        private static FsmObject DoFsmObjectPopup(GUIContent label, Fsm fsm, FsmObject fsmObject, System.Type objectType)
        {
            fsmObject = FsmEditorGUILayout.FsmObjectPopup(label, fsmObject, (fsm != null) ? fsm.Variables.ObjectVariables : null, (FsmVariables.GlobalVariables != null) ? FsmVariables.GlobalVariables.ObjectVariables : null, objectType) ?? new FsmObject("");
            fsmObject.UseVariable = true;
            return fsmObject;
        }

        private static FsmQuaternion DoFsmQuaternionPopup(GUIContent label, Fsm fsm, FsmQuaternion fsmQauternion)
        {
            fsmQauternion = ((FsmQuaternion) FsmEditorGUILayout.Popup(label, fsmQauternion, (fsm != null) ? ((INamedVariable[]) fsm.Variables.QuaternionVariables) : null, (FsmVariables.GlobalVariables != null) ? ((INamedVariable[]) FsmVariables.GlobalVariables.QuaternionVariables) : null)) ?? new FsmQuaternion("");
            fsmQauternion.UseVariable = true;
            return fsmQauternion;
        }

        private static FsmRect DoFsmRectPopup(GUIContent label, Fsm fsm, FsmRect fsmRect)
        {
            fsmRect = ((FsmRect) FsmEditorGUILayout.Popup(label, fsmRect, (fsm != null) ? ((INamedVariable[]) fsm.Variables.RectVariables) : null, (FsmVariables.GlobalVariables != null) ? ((INamedVariable[]) FsmVariables.GlobalVariables.RectVariables) : null)) ?? new FsmRect("");
            fsmRect.UseVariable = true;
            return fsmRect;
        }

        private static FsmString DoFsmStringPopup(GUIContent label, Fsm fsm, FsmString fsmString)
        {
            fsmString = ((FsmString) FsmEditorGUILayout.Popup(label, fsmString, (fsm != null) ? ((INamedVariable[]) fsm.Variables.StringVariables) : null, (FsmVariables.GlobalVariables != null) ? ((INamedVariable[]) FsmVariables.GlobalVariables.StringVariables) : null)) ?? new FsmString("");
            fsmString.UseVariable = true;
            return fsmString;
        }

        private static FsmTexture DoFsmTexturePopup(GUIContent label, Fsm fsm, FsmTexture fsmObject)
        {
            fsmObject = ((FsmTexture) FsmEditorGUILayout.Popup(label, fsmObject, (fsm != null) ? ((INamedVariable[]) fsm.Variables.TextureVariables) : null, (FsmVariables.GlobalVariables != null) ? ((INamedVariable[]) FsmVariables.GlobalVariables.TextureVariables) : null)) ?? new FsmTexture("");
            fsmObject.UseVariable = true;
            return fsmObject;
        }

        private static FsmVector3 DoFsmVector3Popup(GUIContent label, Fsm fsm, FsmVector3 fsmVector3)
        {
            fsmVector3 = ((FsmVector3) FsmEditorGUILayout.Popup(label, fsmVector3, (fsm != null) ? ((INamedVariable[]) fsm.Variables.Vector3Variables) : null, (FsmVariables.GlobalVariables != null) ? ((INamedVariable[]) FsmVariables.GlobalVariables.Vector3Variables) : null)) ?? new FsmVector3("");
            fsmVector3.UseVariable = true;
            return fsmVector3;
        }

        private static void EndVariableEditor(INamedVariable variable)
        {
            EditorGUILayout.EndHorizontal();
            if ((DebugVariables && variable.UseVariable) && !string.IsNullOrEmpty(variable.Name))
            {
                ShowCurrentValue(variable.ToString());
            }
        }

        public static FsmBool FsmBoolField(GUIContent label, Fsm fsm, FsmBool fsmBool)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (fsmBool.UseVariable)
            {
                fsmBool = DoFsmBoolPopup(label, fsm, fsmBool);
            }
            else
            {
                fsmBool.Value = EditorGUILayout.Toggle(label, fsmBool.Value, new GUILayoutOption[0]);
            }
            bool flag = VariableToggle(fsmBool.UseVariable);
            if (flag != fsmBool.UseVariable)
            {
                if (!flag)
                {
                    fsmBool = new FsmBool();
                }
                fsmBool.UseVariable = flag;
            }
            EndVariableEditor(fsmBool);
            return fsmBool;
        }

        public static FsmBool FsmBoolPopup(GUIContent label, Fsm fsm, FsmBool fsmBool)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            fsmBool = DoFsmBoolPopup(label, fsm, fsmBool);
            EndVariableEditor(fsmBool);
            return fsmBool;
        }

        public static FsmColor FsmColorField(GUIContent label, Fsm fsm, FsmColor fsmColor)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (fsmColor.UseVariable)
            {
                fsmColor = DoFsmColorPopup(label, fsm, fsmColor);
            }
            else
            {
                fsmColor.Value = EditorGUILayout.ColorField(label, fsmColor.Value, new GUILayoutOption[0]);
            }
            bool flag = VariableToggle(fsmColor.UseVariable);
            if (flag != fsmColor.UseVariable)
            {
                if (!flag)
                {
                    fsmColor = new FsmColor();
                }
                fsmColor.UseVariable = flag;
            }
            EndVariableEditor(fsmColor);
            return fsmColor;
        }

        public static FsmColor FsmColorPopup(GUIContent label, Fsm fsm, FsmColor fsmColor)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            fsmColor = DoFsmColorPopup(label, fsm, fsmColor);
            EndVariableEditor(fsmColor);
            return fsmColor;
        }

        public static FsmFloat FsmFloatField(GUIContent label, Fsm fsm, FsmFloat fsmFloat)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (fsmFloat.UseVariable)
            {
                fsmFloat = DoFsmFloatPopup(label, fsm, fsmFloat);
            }
            else
            {
                fsmFloat.Value = EditorGUILayout.FloatField(label, fsmFloat.Value, new GUILayoutOption[0]);
            }
            bool flag = VariableToggle(fsmFloat.UseVariable);
            if (flag != fsmFloat.UseVariable)
            {
                if (!flag)
                {
                    fsmFloat = new FsmFloat();
                }
                fsmFloat.UseVariable = flag;
            }
            EndVariableEditor(fsmFloat);
            return fsmFloat;
        }

        public static FsmFloat FsmFloatPopup(GUIContent label, Fsm fsm, FsmFloat fsmFloat)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            fsmFloat = DoFsmFloatPopup(label, fsm, fsmFloat);
            EndVariableEditor(fsmFloat);
            return fsmFloat;
        }

        public static FsmFloat FsmFloatSlider(GUIContent label, Fsm fsm, FsmFloat fsmFloat, float minSliderValue, float maxSliderValue)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (fsmFloat.UseVariable)
            {
                fsmFloat = DoFsmFloatPopup(label, fsm, fsmFloat);
            }
            else
            {
                fsmFloat.Value = FsmEditorGUILayout.FloatSlider(label, fsmFloat.Value, minSliderValue, maxSliderValue);
            }
            bool flag = VariableToggle(fsmFloat.UseVariable);
            if (flag != fsmFloat.UseVariable)
            {
                if (!flag)
                {
                    fsmFloat = new FsmFloat();
                }
                fsmFloat.UseVariable = flag;
            }
            EndVariableEditor(fsmFloat);
            return fsmFloat;
        }

        public static FsmGameObject FsmGameObjectField(GUIContent label, Fsm fsm, FsmGameObject fsmGameObject)
        {
            if (label == null)
            {
                label = GUIContent.none;
            }
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (fsmGameObject.UseVariable)
            {
                fsmGameObject = DoFsmGameObjectPopup(label, fsm, fsmGameObject);
            }
            else
            {
                fsmGameObject.Value = (GameObject) EditorGUILayout.ObjectField(label, fsmGameObject.Value, typeof(GameObject), !FsmEditor.SelectedFsmIsPrefab(), new GUILayoutOption[0]);
            }
            bool flag = VariableToggle(fsmGameObject.UseVariable);
            if (flag != fsmGameObject.UseVariable)
            {
                if (!flag)
                {
                    fsmGameObject = new FsmGameObject("");
                }
                fsmGameObject.UseVariable = flag;
            }
            EndVariableEditor(fsmGameObject);
            return fsmGameObject;
        }

        public static FsmGameObject FsmGameObjectPopup(GUIContent label, Fsm fsm, FsmGameObject fsmGameObject)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            fsmGameObject = DoFsmGameObjectPopup(label, fsm, fsmGameObject);
            EndVariableEditor(fsmGameObject);
            return fsmGameObject;
        }

        public static FsmInt FsmIntField(GUIContent label, Fsm fsm, FsmInt fsmInt, object[] attributes)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (fsmInt.UseVariable)
            {
                fsmInt = DoFsmIntPopup(label, fsm, fsmInt);
            }
            else if (ActionEditor.GetUIHint(attributes) == UIHint.Layer)
            {
                fsmInt.Value = EditorGUILayout.LayerField(label, Convert.ToInt32(fsmInt.Value, CultureInfo.CurrentCulture), new GUILayoutOption[0]);
            }
            else
            {
                fsmInt.Value = EditorGUILayout.IntField(label, fsmInt.Value, new GUILayoutOption[0]);
            }
            bool flag = VariableToggle(fsmInt.UseVariable);
            if (flag != fsmInt.UseVariable)
            {
                if (!flag)
                {
                    fsmInt = new FsmInt();
                }
                fsmInt.UseVariable = flag;
            }
            EndVariableEditor(fsmInt);
            return fsmInt;
        }

        public static FsmInt FsmIntPopup(GUIContent label, Fsm fsm, FsmInt fsmInt)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            fsmInt = DoFsmIntPopup(label, fsm, fsmInt);
            EndVariableEditor(fsmInt);
            return fsmInt;
        }

        public static FsmMaterial FsmMaterialField(GUIContent label, Fsm fsm, FsmMaterial fsmObject)
        {
            if (label == null)
            {
                label = GUIContent.none;
            }
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (fsmObject.UseVariable)
            {
                fsmObject = DoFsmMaterialPopup(label, fsm, fsmObject);
            }
            else
            {
                fsmObject.Value = (Material) EditorGUILayout.ObjectField(label, fsmObject.Value, typeof(Material), !FsmEditor.SelectedFsmIsPrefab(), new GUILayoutOption[0]);
            }
            bool flag = VariableToggle(fsmObject.UseVariable);
            if (flag != fsmObject.UseVariable)
            {
                if (!flag)
                {
                    fsmObject = new FsmMaterial("");
                }
                fsmObject.UseVariable = flag;
            }
            EndVariableEditor(fsmObject);
            return fsmObject;
        }

        public static FsmMaterial FsmMaterialPopup(GUIContent label, Fsm fsm, FsmMaterial fsmObject)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            fsmObject = DoFsmMaterialPopup(label, fsm, fsmObject);
            EndVariableEditor(fsmObject);
            return fsmObject;
        }

        public static FsmObject FsmObjectField(GUIContent label, Fsm fsm, FsmObject fsmObject, System.Type objectType)
        {
            if (label == null)
            {
                label = GUIContent.none;
            }
            if (fsmObject == null)
            {
                FsmObject obj2 = new FsmObject();
                obj2.ObjectType = objectType;
                fsmObject = obj2;
            }
            if (!fsmObject.UseVariable)
            {
                fsmObject.ObjectType = objectType;
            }
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (fsmObject.UseVariable)
            {
                fsmObject = DoFsmObjectPopup(label, fsm, fsmObject, objectType);
            }
            else
            {
                fsmObject.Value = EditorGUILayout.ObjectField(label, fsmObject.Value, fsmObject.ObjectType, !FsmEditor.SelectedFsmIsPrefab(), new GUILayoutOption[0]);
            }
            bool flag = VariableToggle(fsmObject.UseVariable);
            if (flag != fsmObject.UseVariable)
            {
                if (!flag)
                {
                    fsmObject = new FsmObject("");
                }
                fsmObject.UseVariable = flag;
            }
            EndVariableEditor(fsmObject);
            return fsmObject;
        }

        public static FsmObject FsmObjectPopup(GUIContent label, Fsm fsm, FsmObject fsmObject, System.Type objectType)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            fsmObject = DoFsmObjectPopup(label, fsm, fsmObject, objectType);
            EndVariableEditor(fsmObject);
            return fsmObject;
        }

        public static FsmQuaternion FsmQuaternionField(GUIContent label, Fsm fsm, FsmQuaternion fsmQauternion)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (fsmQauternion.UseVariable)
            {
                fsmQauternion = DoFsmQuaternionPopup(label, fsm, fsmQauternion);
            }
            else
            {
                Vector3 euler = EditorGUILayout.Vector3Field(label.text, fsmQauternion.Value.eulerAngles, new GUILayoutOption[0]);
                if (euler != fsmQauternion.Value.eulerAngles)
                {
                    fsmQauternion.Value = Quaternion.Euler(euler);
                }
            }
            bool flag = VariableToggle(fsmQauternion.UseVariable);
            if (flag != fsmQauternion.UseVariable)
            {
                if (!flag)
                {
                    fsmQauternion = new FsmQuaternion();
                }
                fsmQauternion.UseVariable = flag;
            }
            EndVariableEditor(fsmQauternion);
            return fsmQauternion;
        }

        public static FsmQuaternion FsmQuaternionPopup(GUIContent label, Fsm fsm, FsmQuaternion fsmQauternion)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            fsmQauternion = DoFsmQuaternionPopup(label, fsm, fsmQauternion);
            EndVariableEditor(fsmQauternion);
            return fsmQauternion;
        }

        public static FsmRect FsmRectField(GUIContent label, Fsm fsm, FsmRect fsmRect)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (fsmRect.UseVariable)
            {
                fsmRect = DoFsmRectPopup(label, fsm, fsmRect);
            }
            else
            {
                fsmRect.Value = EditorGUILayout.RectField(label.text, fsmRect.Value, new GUILayoutOption[0]);
            }
            bool flag = VariableToggle(fsmRect.UseVariable);
            if (flag != fsmRect.UseVariable)
            {
                if (!flag)
                {
                    fsmRect = new FsmRect();
                }
                fsmRect.UseVariable = flag;
            }
            EndVariableEditor(fsmRect);
            return fsmRect;
        }

        public static FsmRect FsmRectPopup(GUIContent label, Fsm fsm, FsmRect fsmRect)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            fsmRect = DoFsmRectPopup(label, fsm, fsmRect);
            EndVariableEditor(fsmRect);
            return fsmRect;
        }

        public static FsmString FsmStringField(GUIContent label, Fsm fsm, FsmString fsmString, object[] attributes)
        {
            bool flag2;
            if (fsmString.UseVariable)
            {
                EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
                fsmString = DoFsmStringPopup(label, fsm, fsmString);
            }
            else
            {
                bool changed;
                string str;
                EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
                UIHint uIHint = ActionEditor.GetUIHint(attributes);
                switch (uIHint)
                {
                    case UIHint.TextArea:
                        GUILayout.BeginVertical(new GUILayoutOption[0]);
                        GUILayout.Label(label, new GUILayoutOption[0]);
                        fsmString.Value = EditorGUILayout.TextArea(fsmString.Value, FsmEditorStyles.TextArea, new GUILayoutOption[] { GUILayout.MinHeight(44f) });
                        GUILayout.EndVertical();
                        goto Label_0296;

                    case UIHint.Behaviour:
                        fsmString.Value = ActionEditor.EditComponentName(label, fsmString.Value, typeof(Behaviour));
                        goto Label_0296;

                    case UIHint.Script:
                        fsmString.Value = ActionEditor.EditComponentName(label, fsmString.Value, typeof(MonoBehaviour));
                        ActionEditor.TrySetBehaviourContext(fsmString.Value);
                        goto Label_0296;

                    case UIHint.Method:
                        fsmString.Value = ActionEditor.EditMethodName(label, fsmString.Value, false);
                        goto Label_0296;

                    case UIHint.Animation:
                        fsmString.Value = EditorGUILayout.TextField(label, fsmString.Value, new GUILayoutOption[0]);
                        changed = GUI.changed;
                        GUI.changed = false;
                        str = FsmEditorGUILayout.AnimationNamePopup(ActionEditor.GameObjectContext);
                        if (GUI.changed && (str != ""))
                        {
                            fsmString.Value = str;
                        }
                        if (!GUI.changed)
                        {
                            GUI.changed = changed;
                        }
                        goto Label_0296;

                    case UIHint.Tag:
                        fsmString.Value = EditorGUILayout.TagField(label, fsmString.Value, new GUILayoutOption[0]);
                        goto Label_0296;

                    case UIHint.ScriptComponent:
                        fsmString.Value = EditorGUILayout.TextField(label, fsmString.Value, new GUILayoutOption[0]);
                        changed = GUI.changed;
                        GUI.changed = false;
                        str = FsmEditorGUILayout.ScriptListPopup();
                        if (GUI.changed && (str != ""))
                        {
                            fsmString.Value = str;
                        }
                        if (!GUI.changed)
                        {
                            GUI.changed = changed;
                        }
                        goto Label_0296;

                    case UIHint.FsmName:
                        fsmString.Value = ActionEditor.EditFsmName(label, fsmString.Value);
                        goto Label_0296;

                    case UIHint.FsmEvent:
                        fsmString.Value = ActionEditor.EditFsmEvent(label, fsmString.Value);
                        goto Label_0296;

                    case UIHint.FsmFloat:
                    case UIHint.FsmInt:
                    case UIHint.FsmBool:
                    case UIHint.FsmString:
                    case UIHint.FsmVector3:
                    case UIHint.FsmGameObject:
                    case UIHint.FsmColor:
                    case UIHint.FsmRect:
                    case UIHint.FsmMaterial:
                    case UIHint.FsmTexture:
                    case UIHint.FsmQuaternion:
                    case UIHint.FsmObject:
                        fsmString.Value = ActionEditor.EditFsmVariableName(label, fsmString.Value, uIHint);
                        goto Label_0296;
                }
                fsmString.Value = EditorGUILayout.TextField(label, fsmString.Value, new GUILayoutOption[0]);
            }
        Label_0296:
            flag2 = VariableToggle(fsmString.UseVariable);
            if (flag2 != fsmString.UseVariable)
            {
                if (!flag2)
                {
                    fsmString = new FsmString();
                }
                fsmString.UseVariable = flag2;
            }
            EndVariableEditor(fsmString);
            return fsmString;
        }

        public static FsmString FsmStringPopup(GUIContent label, Fsm fsm, FsmString fsmString)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            fsmString = DoFsmStringPopup(label, fsm, fsmString);
            EndVariableEditor(fsmString);
            return fsmString;
        }

        public static FsmTexture FsmTextureField(GUIContent label, Fsm fsm, FsmTexture fsmObject)
        {
            if (label == null)
            {
                label = GUIContent.none;
            }
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (fsmObject.UseVariable)
            {
                fsmObject = DoFsmTexturePopup(label, fsm, fsmObject);
            }
            else
            {
                fsmObject.Value = (Texture) EditorGUILayout.ObjectField(label, fsmObject.Value, typeof(Texture), !FsmEditor.SelectedFsmIsPrefab(), new GUILayoutOption[0]);
            }
            bool flag = VariableToggle(fsmObject.UseVariable);
            if (flag != fsmObject.UseVariable)
            {
                if (!flag)
                {
                    fsmObject = new FsmTexture("");
                }
                fsmObject.UseVariable = flag;
            }
            EndVariableEditor(fsmObject);
            return fsmObject;
        }

        public static FsmTexture FsmTexturePopup(GUIContent label, Fsm fsm, FsmTexture fsmObject)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            fsmObject = DoFsmTexturePopup(label, fsm, fsmObject);
            EndVariableEditor(fsmObject);
            return fsmObject;
        }

        public static FsmVector3 FsmVector3Field(GUIContent label, Fsm fsm, FsmVector3 fsmVector3)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (fsmVector3.UseVariable)
            {
                fsmVector3 = DoFsmVector3Popup(label, fsm, fsmVector3);
            }
            else
            {
                fsmVector3.Value = EditorGUILayout.Vector3Field(label.text, fsmVector3.Value, new GUILayoutOption[0]);
            }
            bool flag = VariableToggle(fsmVector3.UseVariable);
            if (flag != fsmVector3.UseVariable)
            {
                if (!flag)
                {
                    fsmVector3 = new FsmVector3();
                }
                fsmVector3.UseVariable = flag;
            }
            EndVariableEditor(fsmVector3);
            return fsmVector3;
        }

        public static FsmVector3 FsmVector3Popup(GUIContent label, Fsm fsm, FsmVector3 fsmVector3)
        {
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            fsmVector3 = DoFsmVector3Popup(label, fsm, fsmVector3);
            EndVariableEditor(fsmVector3);
            return fsmVector3;
        }

        private static void ShowCurrentValue(string value)
        {
            FsmEditorGUILayout.ReadonlyTextField(value, new GUILayoutOption[0]);
        }

        private static bool VariableToggle(bool useVariable)
        {
            GUI.backgroundColor = Color.white;
            FsmEditorStyles.VariableButton.tooltip = (DragAndDropManager.mode == DragAndDropManager.DragMode.None) ? "使用变量" : null;
            return GUILayout.Toggle(useVariable, FsmEditorStyles.VariableButton, FsmEditorStyles.MiniButtonPadded, new GUILayoutOption[0]);
        }

        public static bool DebugVariables
        {
            [CompilerGenerated]
            get
            {
                return DebugVariables__BackingField;
            }
            [CompilerGenerated]
            set
            {
                DebugVariables__BackingField = value;
            }
        }
    }
}

